From 9e4542ca2b6322c56bc1dc8aa26d091bc5a4a158 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sat, 17 Mar 2012 23:54:49 +0000 Subject: [PATCH] add bablformats that match the hosts endianness --- extensions/Makefile.am | 2 + extensions/cairo.c | 86 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 extensions/cairo.c diff --git a/extensions/Makefile.am b/extensions/Makefile.am index e8ad111..fac0123 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -14,6 +14,7 @@ AM_CPPFLAGS = \ extdir = $(libdir)/babl-@BABL_API_VERSION@ ext_LTLIBRARIES = \ + cairo.la \ CIE.la \ gegl-fixups.la \ gggl-lies.la \ @@ -22,6 +23,7 @@ ext_LTLIBRARIES = \ naive-CMYK.la \ sse-fixups.la +cairo_la_SOURCES = cairo.c CIE_la_SOURCES = CIE.c gegl_fixups_la_SOURCES = gegl-fixups.c gggl_lies_la_SOURCES = gggl-lies.c diff --git a/extensions/cairo.c b/extensions/cairo.c new file mode 100644 index 0000000..3a0732f --- /dev/null +++ b/extensions/cairo.c @@ -0,0 +1,86 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2012 Øyvind Kolås. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#include +#include "babl.h" + +int init (void); + +int +init (void) +{ + int testint = 23; + char *testchar = (char*) &testint; + int littleendian = (testchar[0] == 23); + + if (littleendian) + { + babl_format_new ( + "name", "cairo-ARGB32", + babl_model ("R'aG'aB'aA"), + babl_type ("u8"), + babl_component ("B'a"), + babl_component ("G'a"), + babl_component ("R'a"), + babl_component ("A"), + NULL + ); + + babl_format_new ( + "name", "cairo-RGB24", + babl_model ("R'G'B'"), + babl_type ("u8"), + babl_component ("B'"), + babl_component ("G'"), + babl_component ("R'"), + babl_component ("PAD"), + NULL + ); + } + else + { + babl_format_new ( + "name", "cairo-ARGB32", + babl_model ("R'G'B'A"), + babl_type ("u8"), + babl_component ("A"), + babl_component ("R'a"), + babl_component ("G'a"), + babl_component ("B'a"), + NULL + ); + babl_format_new ( + "name", "cairo-RGB24", + babl_model ("R'G'B'"), + babl_type ("u8"), + babl_component ("PAD"), + babl_component ("R'"), + babl_component ("G'"), + babl_component ("B'"), + NULL + ); + } + babl_format_new ( + "name", "cairo-A8", + babl_model ("YA"), + babl_type ("u8"), + babl_component ("A"), + NULL + ); + return 0; +} -- 2.30.2